package com.ndp.fb.model.fbagent.param;

/**
 * Created by Rock on 2015/1/14 0014.
 */

/**
 * 具有 standard 权限后，对优先级进行调整，首先满足用户界面操作对Facebook 请求的优先级，保证用户等待时间最短
 * 所有用户界面操作的API 请求优先级，均修改为 500，最高级别，别先进先出。
 * by hunk  2015/6/15
 * Created by Rock on 2015/1/14 0014.
 */
public enum APIPriority {
    //所有的DeleteObject请求
    DeleteOjbect(2, "DeleteOjbect", false),
    //用来换图片
    GetAdCreative(1, "GetAdCreative", true),
    FetchAdsetOfferBid(500, "fetchadsetofferbid", true),

    //0.账号同步应用 从6调整到1
    FetchConnectionobjects(501, "connectionobjects", true),
    //1.3获取视频缩略图
    FetchAdVideoThumbnail(502, "ad_video_thumbnail", false),

    //1.5获取账号下customaudiences的数据
    FetchCustomaudiences(503, "customaudiences", false),

    //3.暂停广告
    PauseAdGroup(504, "adgroups", false),

    //激活广告
    ActiveAdGroup(505, "adgroups", false),
    //7.素材上传
    //同步等待
    UploadImage(506, "adimages", true),
    UploadVideo(507, "advideos", true),

    ////异步
    UploadImageAsyn(508, "adimages", false),
    UploadVideoAsyn(509, "advideos", false),
    //8.广告创建
    CreateAdCreative(510, "adcreatives", false),
    CreateAdCampaignGroups(512, "adcampaign_groups", false),
    CreateAdSet(513, "adcampaigns", false),
    CreateAdGroups(514, "adgroups", false),
    //5.用户定位
    UserAudienceCategory(515, "broadtargetingcategories", true),
    UserAudienceReach(516, "reachestimate", false),
    //获取用户权限
    GetUserpermissions(517, "userpermissions", false),

    //获取账户
    GetEntrustAccounts(518, "entrustAccounts", false),

    //获取accesstoken
    GetAccessToken(519, "entrustAccounts", false),

    //同步广告账户下的ins账号
    SyncIns(520, "syncins", false),

    //6.创建产品目录
    ProductCatalogCreate(600, "createproductcatalog", false),
    ProductFeedCreate(601, "createproductfeed", false),
    ProductFeedFetch(602, "fetchproductfeed", false),
    ProductSetCreate(603, "createproductset", false),
    ProductFeedUpdate(604, "updateproductfeed", false),

    ModifyAdGroupStats(950, "modify_adgroup_stats", true),
    ModifyAdSet(951, "modify_adset", true),

    //1.获取账号下compaign。adset的数量
    FetchAdCompaignGroupsCount(1000, "adcampaign_groups", true),
    FetchAdcampaignsCount(1001, "adcampaigns", true),

    CreateInsightsAdGroupAsyncJob(1003, "CreateInsightsAdGroupAsyncJob", false),

    //2.获取compaign. adset.ad的统计数据
    FetchAdgroupstats(2000, "adgroupstats", false),
    //获取compaign. adset.ad的增量统计数据
    FetchAdgroupstatsIncrement(2002, "adgroupstats_increment", false),

    //4.调整预算
    ChangeBudget(4000, "adcampaigns", false),


    //6.账号同步应用
    //FetchConnectionobjects(6000,"connectionobjects"),


    //获取业务数据
    FetchAdgroupBusiness(8010, "fetchadgroupbusiness", false),
    FetchAdcampaignBusiness(8011, "fetchadcampaignbusiness", false),
    FetchAdSetBusiness(8012, "fetchadsetbusiness", false),
    FetchAdImageBusiness(8013, "fetchadimagebusiness", false),
    //9.报表生成
    CreateReportJobId(9001, "reportstats", false),
    FetchJobId(9002, "jobId", false),
    FetchReportStats(9003, "reportstats", false),

    //FBme
    GetFBMe(10004, "fbme", false),
    //统计数据相关调度
    GetInsightsAdGroupAsyncJobStatus(20004, "GetInsightsAdGroupAsyncJobStatus", false),
    GetInsightsAdGroupAsyncJobData(20005, "GetInsightsAdGroupAsyncJobData", false),
    
    GetAdAccountActivities(30001, "GetAdAccountActivities", false),
    
    UpdateAdSetTime(89998, "updateAdSetTime", false),
    //更新adGroupupdateTime请求
    UpdateAdGroupTime(89999, "updateAdGroupTime", false),
    GetCampaignActivities(99998, "GetCampaignActivities", false),
    //默认请求
    Default(99999, "default", true);

    private int code;

    private boolean wait;

    private Double score;

    public static final Double d = 10000000D;

    private APIPriority(int code, String url, boolean wait) {
        this.code = code;
        this.wait = wait;
    }

    public static APIPriority getAPIPriorityByCode(String code) {
        for (APIPriority c : APIPriority.values()) {
            if (c.code == Integer.parseInt(code)) {
                return c;
            }
        }
        return null;
    }

    public int getCode() {
        return code;
    }

    public Double getScore() {
        return code * d;
    }

    public boolean isWait() {
        return wait;
    }
}
